package com.jiantong.admin.controller.dongjiantong;

import com.google.common.collect.Maps;
import com.jiantong.admin.controller.DjtBaseController;

import com.jiantong.admin.model.PagingMz;

import com.jiantong.user.model.BreedFactory;
import com.jiantong.user.model.GovernmentUserDuty;
import com.jiantong.user.model.User;
import com.jiantong.user.model.UserProfile;
import com.jiantong.user.service.*;
import com.jiantong.work.model.*;
import com.jiantong.work.model.yangzhibaoxian.InsuranceTemplate;
import com.jiantong.work.service.*;
import com.jiantong.work.service.FeedReportReadService;

import com.jiantong.work.service.yangzhibaoxian.InsuranceTemplateService;
import io.terminus.boot.rpc.common.annotation.RpcConsumer;
import io.terminus.common.model.Paging;

import com.jiantong.admin.dto.CityAreaDto;

import com.jiantong.work.model.ProductionReport;
import com.jiantong.work.service.ProductionReportReadService;
import io.terminus.common.model.Response;
import io.terminus.pampas.openplatform.exceptions.OPServerException;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.map.HashedMap;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;

import org.springframework.web.bind.annotation.*;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;
import java.util.HashMap;
import java.util.Map;

import java.util.*;


/**
 * Created by cao on 2017/7/17.
 * 养殖档案
 */
@Slf4j
@Controller
@RequestMapping("/djt/breedarch/")
public class BreedArchivesController extends DjtBaseController {

    @RpcConsumer
    private InsuranceTemplateService insuranceTemplateService;
    private static final String BaseViews = VIEWS + "breedarch/";
    @RpcConsumer
    private PollutionControlReadService pollutionControlReadService;
    @RpcConsumer
    private PollutionControlWriteService pollutionControlWriteService;
    @RpcConsumer
    private MaterialPurchaseRecordReadService materialPurchaseRecordReadService;
    @RpcConsumer
    private MaterialPurchaseRecordWriteService materialPurchaseRecordWriteService;
    @RpcConsumer
    private BreedFactoryReadService breedFactoryReadService;
    @RpcConsumer
    private BreedFactoryWriteService breedFactoryWriteService;
    @RpcConsumer
    private ProductionReportReadService productionReportReadService;
    @RpcConsumer
    private ProductionReportWriteService productionReportWriteService;
    @RpcConsumer
    private FeedReportReadService feedReportReadService;
    @RpcConsumer
    private FeedReportWriteService feedReportWriteService;
    @RpcConsumer
    private VeterinaryDrugsReportReadService veterinaryDrugsReportReadService;
    @RpcConsumer
    private VeterinaryDrugsReportWriteService veterinaryDrugsReportWriteService;
    @RpcConsumer
    private ImmunizationRecordReadService immunizationRecordReadService;
    @RpcConsumer
    private ImmunizationRecordWriteService immunizationRecordWriteService;

    @RpcConsumer
    private DisinfectReportReadService disinfectReportReadService;
    @RpcConsumer
    private DisinfectReportWriteService disinfectReportWriteService;
    @RpcConsumer
    private DiagnosisReportReadService diagnosisReportReadService;
    @RpcConsumer
    private DiagnosisReportWriteService diagnosisReportWriteService;
    @RpcConsumer
    private ImmunizationDetectionReadService immunizationDetectionReadService;
    @RpcConsumer
    private ImmunizationDetectionWriteService immunizationDetectionWriteService;
    @RpcConsumer
    private QuarantineCenterHarmlessReadService quarantineCenterHarmlessReadService;
    @RpcConsumer
    private QuarantineCenterHarmlessWriteService quarantineCenterHarmlessWriteService;
    @RpcConsumer
    private DrugPurchaseRecordReadService drugPurchaseRecordReadService;
    @RpcConsumer
    private DrugPurchaseRecordWriteService drugPurchaseRecordWriteService;
    @RpcConsumer
    private VaccinePurchaseRecordReadService vaccinePurchaseRecordReadService;
    @RpcConsumer
    private VaccinePurchaseRecordWriteService vaccinePurchaseRecordWriteService;
    @RpcConsumer
    private SeedPurchaseRecordReadService seedPurchaseRecordReadService;
    @RpcConsumer
    private SeedPurchaseRecordWriteService seedPurchaseRecordWriteService;


    @RpcConsumer
    private OtherPurchaseRecordReadService otherPurchaseRecordReadService;
    @RpcConsumer
    private OtherPurchaseRecordWriteService otherPurchaseRecordWriteService;
    @RpcConsumer
    private BeastsBreedStockMessageReadService beastsBreedStockMessageReadService;
    @RpcConsumer
    private ImmunizationSubRecordReadService immunizationSubRecordReadService;
    @RpcConsumer
    private ImmunizationSubRecordWriteService immunizationSubRecordWriteService;
    @RpcConsumer
    private UserReadService userReadService;
    @RpcConsumer
    private UserProfileReadService userProfileReadService;
    @RpcConsumer
    private GovernmentUserDutyReadService governmentUserDutyReadService;

    @ResponseBody
    @RequestMapping("InsuranceTemplate")
    public List<InsuranceTemplate> selectInsuranceTemplate() {

        return insuranceTemplateService.list(new HashMap()).getResult();
    }

    //首页存栏分析
    @GetMapping("dashboard")
    private String BreedArchivesDashboard(Model model, HttpServletRequest request, HttpServletResponse response1) {

        Map mapuser = getarea(response1, request);

        UserProfile userProfile = (UserProfile) mapuser.get("userProfile");

        model.addAttribute("username", mapuser.get("username"));
        List<CityAreaDto> cityAreaDtoList = serachCityAreaDtoInBreefctory();
        Response<List<Integer>> response = breedFactoryReadService.findQuantityByType1(null, userProfile.getRegionId());
        Map<String, Integer> map = Maps.newHashMap();
        for (int i = 0; i < response.getResult().size(); i++) {
            switch (i + 1) {
                case 1:
                    map.put("pig", response.getResult().get(i));
                    break;
                case 2:
                    map.put("cow", response.getResult().get(i));
                    break;
                case 3:
                    map.put("sheep", response.getResult().get(i));
                break;
                case 4:
                    map.put("poultry", response.getResult().get(i));
                    break;
            }
        }
        model.addAttribute("cityAreaDtoList", cityAreaDtoList);
        model.addAttribute("cunlanshu", map);

        List<BreedFactory> breedFactoryList = findAllBreedFactory();
        List<Long> longList = new ArrayList<>();
        for (BreedFactory breedFactory : breedFactoryList) {
            longList.add(breedFactory.getId());
        }
        Map map1 = new HashMap();
        map1.put("breedFactoryIds", longList);
        Response<Paging<ProductionReport>> pagingResponse = productionReportReadService.pagingbytimes(1, 10000, map1);
        Long a = 0L;
        Long b = 0L;
        Long c = 0L;
        Long d = 0L;
        if (pagingResponse.getResult() != null && pagingResponse.getResult().getData().size() != 0) {
            for (ProductionReport productionReport : pagingResponse.getResult().getData()) {

                a += productionReport.getBirthQuantity();
                b += productionReport.getInQuantity();
                c += productionReport.getOutQuantity();
                d += productionReport.getDeathQuantity();
            }
        }

        model.addAttribute("a", a);
        model.addAttribute("b", b);
        model.addAttribute("c", c);
        model.addAttribute("d", d);

        List<String> stringList = breedFactoryReadService.serachAllCity();
        List<Map> mapList = new ArrayList<>();
        for (String city : stringList) {
            Map map3 = new HashMap();
            Long stock = 0L;
            Map map2 = new HashMap();
            map2.put("city", city);
            Response<List<BreedFactory>> listResponse3 = breedFactoryReadService.findByArea(map2);
            List<BreedFactory> listq = listResponse3.getResult();
            if (listq != null) {
                for (BreedFactory breedFactory : listq) {
                    if (breedFactory.getStockQuantity() != null && breedFactory.getStockQuantity() != 0) {
                        stock += breedFactory.getStockQuantity();

                    }

                }
            }
            map3.put("city", city);
            map3.put("Stock", stock);
            mapList.add(map3);
        }


        model.addAttribute("Stocks", mapList);

        return BaseViews + "dashboard";
    }


    @ResponseBody
    @RequestMapping("dashboardchert")
    public List<Map> tttt() {
        List<String> stringList = breedFactoryReadService.serachAllCity();
        List<Map> mapList = new ArrayList<>();
        for (String city : stringList) {
            Map map3 = new HashMap();
            Long stock1 = 0L;
            Long stock2 = 0L;
            Long stock3 = 0L;
            Long stock4 = 0L;
            Map map2 = new HashMap();
            map2.put("city", city);
            Response<List<BreedFactory>> listResponse3 = breedFactoryReadService.findByArea(map2);
            List<BreedFactory> listq = listResponse3.getResult();
            for (BreedFactory breedFactory : listq) {
                if (breedFactory.getStockQuantity() != null && breedFactory.getStockQuantity() != 0) {
                    switch (breedFactory.getBreedType()) {
                        case 1:
                            stock1 += breedFactory.getStockQuantity();
                            break;
                        case 2:
                            stock2 += breedFactory.getStockQuantity();
                            break;
                        case 3:
                            stock3 += breedFactory.getStockQuantity();
                            break;
                        case 4:
                            stock4 += breedFactory.getStockQuantity();
                            break;
                    }
                }

            }
            map3.put("city", city);
            map3.put("Stock1", stock1);
            map3.put("Stock2", stock2);
            map3.put("Stock3", stock3);
            map3.put("Stock4", stock4);
            mapList.add(map3);
        }

        return mapList;

    }

    @GetMapping("proddetail")
    private String proddetail() {
        return BaseViews + "proddetail";
    }

    @GetMapping("feeddetail")
    private String feeddetail() {
        return BaseViews + "feeddetail";
    }

    @GetMapping("veterdetail")
    private String veterdetail() {
        return BaseViews + "veterdetail";
    }

    @GetMapping("ImmunizationRecorddetail")
    private String ImmunizationRecorddetail() {
        return BaseViews + "ImmunizationRecorddetail";
    }

    @GetMapping("disinfectReportdetail")
    private String disinfectReportdetail() {
        return BaseViews + "disinfectReportdetail";
    }

    @GetMapping("diagnosisReportdetail")
    private String diagnosisReportdetail() {
        return BaseViews + "diagnosisReportdetail";
    }

    @GetMapping("ImmunizationDetectiondetail")
    private String ImmunizationDetectiondetail() {
        return BaseViews + "ImmunizationDetectiondetail";
    }

    @GetMapping("quaranHarmlessdetail")
    private String quaranHarmlessdetail() {
        return BaseViews + "quaranHarmlessdetail";
    }

    @GetMapping("drugPurchasedetail")
    private String drugPurchasedetail() {
        return BaseViews + "drugPurchasedetail";
    }

    @GetMapping("vaccinePurchasedetail")
    private String vaccinePurchasedetail() {
        return BaseViews + "vaccinePurchasedetail";
    }

    @GetMapping("seedPurchasedetail")
    private String seedPurchasedetail() {
        return BaseViews + "seedPurchasedetail";
    }

    @GetMapping("OtherPurchasedetail")
    private String OtherPurchasedetail() {
        return BaseViews + "OtherPurchasedetail";
    }

    @GetMapping("file_pollutedetail")
    private String file_pollutedetail() {
        return BaseViews + "file_pollutedetail";
    }

    //免疫分析
    @GetMapping("immunestat")
    private String immunestat(
            Model model, HttpServletRequest request, HttpServletResponse response) {


        Map mapuser = getarea(response, request);

        model.addAttribute("username", mapuser.get("username"));
        List<CityAreaDto> cityAreaDtoList = serachCityAreaDtoInBreefctory();
        model.addAttribute("cityAreaDtoList", cityAreaDtoList);
        List<String> regions = new ArrayList<>();
        for (CityAreaDto cityAreaDto : cityAreaDtoList) {
            for (String a : cityAreaDto.getRegions()) {
                regions.add(a);
            }

        }
        List<Map> mapList = new ArrayList<>();
        for (String b : regions) {
            List<BreedFactory> list = findFactoryIdByArea(b, -1);
            List<Long> longList = new ArrayList<>();
            for (BreedFactory breedFactory : list) {
                longList.add(breedFactory.getId());
            }
            if (longList.size() == 0) {
                longList.add(-1L);
            }
            Map map = new HashMap();
            map.put("breedFactoryIds", longList);
            List<ImmunizationRecord> immunizationRecordList1 = immunizationRecordReadService.pagingImmunizationRecordGqv1(1, 10000, map).getResult().getData();
            List<Long> longlist7 = new ArrayList<>();
            for (ImmunizationRecord immunizationRecord : immunizationRecordList1) {
                longlist7.add(immunizationRecord.getId());
            }
            Map map6 = new HashMap();
            if (longlist7.size() == 0) {
                longlist7.add(-1L);
            }
            map6.put("vaccineIds", longlist7);
            Response<Paging<ImmunizationSubRecord>> pagingResponse = immunizationSubRecordReadService.pagingImmunizationRecordGqv1(1, 10000, map6);
            List<ImmunizationSubRecord> immunizationRecordList = pagingResponse.getResult().getData();
            Long a = 0L;
            if (immunizationRecordList.size() > 0) {
                for (ImmunizationSubRecord immunizationRecord : immunizationRecordList) {
                    a += immunizationRecord.getTimes();
                }
            }
            Map map1 = new HashMap();
            map1.put("regin", b);
            map1.put("times", a);
            mapList.add(map1);

        }
        Collections.sort(mapList, new Comparator<Map>() {
            @Override
            public int compare(Map o1, Map o2) {
                if ((Long) o1.get("times") > (Long) o2.get("times")) {
                    return -1;
                }
                if (o1.get("times") == o2.get("times")) {
                    return 0;
                }
                return 1;
            }
        });

        List<Map> mapList1 = new ArrayList<>();
        if (mapList.size() >= 0 && mapList.size() <= 9) {
            mapList1 = mapList;
        } else {
            mapList1 = mapList.subList(0, 9);
        }

        model.addAttribute("maplist", mapList1);
        List<Map<String, Object>> list = immunizationSubRecordReadService.findAlltimesAlltype(new HashMap());
        model.addAttribute("maplist1", list);
        return BaseViews + "immunestat";
    }

    @ResponseBody
    @RequestMapping("nowtyearim")
    public List tttttt(@RequestParam Integer productType) {

        Date date = new Date();
        Integer year = date.getYear() + 1900;
        Integer month = date.getMonth() + 1;
        List<Integer> list = new ArrayList();
        list.add(month);
        Integer a = month;
        while (a > 1) {
            a = a - 1;
            list.add(a);
        }
        List<Map> mapList = new ArrayList<>();
        Map map10 = new HashMap();
        map10.put("breedType", productType);
        List<ImmunizationRecord> list10 = immunizationRecordReadService.pagingImmunizationRecordGqv1(1, 10000, map10).getResult().getData();
        List<Long> longList = new ArrayList<>();
        for (ImmunizationRecord immunizationRecord : list10) {
            longList.add(immunizationRecord.getId());
        }
        if (longList.size() == 0) {
            longList.add(-1L);
        }
        for (Integer b : list) {
            Map map1 = new HashMap();
            int times = 0;
            Map map = new HashMap();
            map.put("year", year);
            map.put("month", b);
            map.put("vaccineIds", longList);
            List<ImmunizationSubRecord> immunizationRecordList = immunizationSubRecordReadService.pagingImmunizationRecordGqv1(1, 10000, map).getResult().getData();
            if (immunizationRecordList != null && immunizationRecordList.size() != 0) {
                for (ImmunizationSubRecord immunizationRecord : immunizationRecordList) {
                    times += immunizationRecord.getTimes();
                }
                map1.put("times", times);

            } else {
                map1.put("times", 0);

            }
            mapList.add(map1);
        }
        Collections.reverse(mapList);
        return mapList;

    }

    @ResponseBody
    @RequestMapping("feeds1")
    public List tttttt999(@RequestParam Integer productName) {

        Date date = new Date();
        Integer year = date.getYear() + 1900;
        Integer month = date.getMonth() + 1;
        List<Integer> list = new ArrayList();
        list.add(month);
        Integer a = month;
        while (a > 1) {
            a = a - 1;
            list.add(a);
        }
        List<Map> mapList = new ArrayList<>();
        for (Integer b : list) {
            Map map1 = new HashMap();
            int prices = 0;
            int price = 0;
            Map map = new HashMap();
            map.put("year", year);
            map.put("month", b);
            map.put("productName", productName);
            List<MaterialPurchaseRecord> materialPurchaseRecords = materialPurchaseRecordReadService.pagingMaterialPurchaseRecordByKeyWords(1, 10000, map).getResult().getData();
            if (materialPurchaseRecords != null && materialPurchaseRecords.size() != 0) {
                for (MaterialPurchaseRecord materialPurchaseRecord : materialPurchaseRecords) {
                    prices += materialPurchaseRecord.getPrice();
                }
                price = prices / materialPurchaseRecords.size();
                map1.put("price", price);

            } else {
                map1.put("price", 0);

            }
            mapList.add(map1);
        }
        Collections.reverse(mapList);
        return mapList;

    }


    @ResponseBody
    @RequestMapping("nowtyearim1")
    public List tttttt1(@RequestParam String city, @RequestParam(required = false) Date time1,
                        @RequestParam(required = false) Date time2) {

        List<BreedFactory> breedFactoryList = findFactoryIdByArea(city, -1);
        List<Long> longList = new ArrayList<>();
        for (BreedFactory breedFactory : breedFactoryList) {
            longList.add(breedFactory.getId());
        }
        Map mapq = new HashMap();
        mapq.put("breedFactoryIds", longList);
        List<ImmunizationRecord> immunizationRecordList1 = immunizationRecordReadService.pagingImmunizationRecordGqv1(1, 10000, mapq).getResult().getData();
        List<Integer> list = new ArrayList();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);

        List maplist = new ArrayList();
        for (int p : list) {
            List<Long> vacc = new ArrayList<>();
            for (ImmunizationRecord immunizationRecord : immunizationRecordList1) {
                if (immunizationRecord.getBreedType() == p) {
                    vacc.add(immunizationRecord.getId());
                }
            }
            Map map = new HashMap();
            if (vacc.size() == 0) {
                vacc.add(-1L);
            }
            map.put("vaccineIds", vacc);
            map.put("fromDate", time1);
            map.put("toDate", time2);
            Response<Paging<ImmunizationSubRecord>> pagingResponse = immunizationSubRecordReadService.pagingImmunizationRecordGqv1(1, 10000, map);
            List<ImmunizationSubRecord> immunizationRecordList = pagingResponse.getResult().getData();
            int a = 0;
            if (immunizationRecordList != null) {
                for (ImmunizationSubRecord immunizationRecord : immunizationRecordList) {
                    a += immunizationRecord.getTimes();
                }
            }
            Map map1 = new HashMap();
            map1.put("city", city);
            map1.put("type", a);
            maplist.add(map1);
        }

        return maplist;


    }


    @ResponseBody
    @RequestMapping("find")

    public ImmunizationRecord find(@RequestParam Long id) {

        return immunizationRecordReadService.findById(id).getResult();
    }

    //原料良种分析
    @GetMapping("feedsstat")
    private String feedsstat(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map mapuser = getarea(response, request);

        model.addAttribute("username", mapuser.get("username"));

        List<Integer> productName = new ArrayList();
        productName.add(1);
        productName.add(2);
        productName.add(3);
        productName.add(4);
        productName.add(5);
        List<Map> mapList = new ArrayList<>();
        for (int a : productName) {
            Map mapprice = new HashMap();
            int price = 0;
            int prices = 0;
            Map map = new HashMap();
            map.put("productName", a);
            List<MaterialPurchaseRecord> materialPurchaseRecordList = materialPurchaseRecordReadService.pagingMaterialPurchaseRecordByKeyWords(1, 10000, map).getResult().getData();
            if (materialPurchaseRecordList != null && materialPurchaseRecordList.size() != 0) {
                for (MaterialPurchaseRecord materialPurchaseRecord : materialPurchaseRecordList) {
                    prices += materialPurchaseRecord.getPrice();
                }
                price = prices / materialPurchaseRecordList.size();
                mapprice.put("type", a);
                mapprice.put("price", price);
            } else {
                mapprice.put("type", a);
                mapprice.put("price", 0);
            }

            mapList.add(mapprice);

        }


        Collections.sort(mapList, new Comparator<Map>() {
            @Override
            public int compare(Map o1, Map o2) {
                if ((int) o1.get("price") > (int) o2.get("price")) {
                    return -1;
                }
                if (o1.get("price") == o2.get("price")) {
                    return 0;
                }
                return 1;
            }
        });
        model.addAttribute("maplist", mapList);
        List<String> regions = new ArrayList<>();
        List<CityAreaDto> list = serachCityAreaDtoInBreefctory();
        for (CityAreaDto cityAreaDto : list) {
            for (String region : cityAreaDto.getRegions()) {
                regions.add(region);
            }
        }
        List<Map> mapList1 = new ArrayList<>();
        for (String region : regions) {
            Map mapmax = new HashMap();
            int a = 0;
            Map map11 = new HashMap();
            map11.put("region", region);
            List<Long> longList = breedFactoryReadService.serachIdsByarea(map11);
            Map mapregion = new HashMap();
            mapregion.put("breedFactoryIds", longList);

            List<MaterialPurchaseRecord> materialPurchaseRecordList = materialPurchaseRecordReadService.pagingMaterialPurchaseRecordByKeyWords(1, 10000, mapregion).getResult().getData();
            if (materialPurchaseRecordList.size() != 0) {
                for (MaterialPurchaseRecord materialPurchaseRecord : materialPurchaseRecordList) {
                    a += materialPurchaseRecord.getQuantity();
                }
                mapmax.put("city", region);
                mapmax.put("sum", a);
            } else {
                mapmax.put("city", region);
                mapmax.put("sum", 0);
            }
            mapList1.add(mapmax);

        }

        Collections.sort(mapList1, new Comparator<Map>() {
            @Override
            public int compare(Map o1, Map o2) {
                if ((int) o1.get("sum") > (int) o2.get("sum")) {
                    return -1;
                }
                if (o1.get("sum") == o2.get("sum")) {
                    return 0;
                }
                return 1;
            }
        });

        model.addAttribute("mapList1", mapList1);
        return BaseViews + "feedsstat";
    }

    //无害化分析
    @GetMapping("harmstat")
    private String harmstat() {
        return BaseViews + "harmstat";
    }

    //生产中心
    //生产记录
    @GetMapping("prodrecord")
    private String ProdRecord(Model model, HttpServletRequest request, HttpServletResponse response) {
        // List <CityAreaDto> cityAreaDtoList=serachCityAreaDtoInBreefctory();
        // List<BreedFactory> breedFactoryList=findAllBreedFactory();
        Map map = getarea(response, request);
        model.addAttribute("cityAreaDtoList", map.get("cityAreaDtoList"));
        model.addAttribute("breedFactoryList", map.get("breedFactorys"));
        model.addAttribute("username", map.get("username"));
        return BaseViews + "prod_record";
    }

    //饲料记录
    @GetMapping("feedReport")
    private String FeedReport(Model model, HttpServletRequest request, HttpServletResponse response) {  //List <CityAreaDto> cityAreaDtoList=serachCityAreaDtoInBreefctory();
        // List<BreedFactory> breedFactoryList=findAllBreedFactory();
        Map map = getarea(response, request);
        model.addAttribute("cityAreaDtoList", map.get("cityAreaDtoList"));
        model.addAttribute("breedFactoryList", map.get("breedFactorys"));
        model.addAttribute("username", map.get("username"));
        return BaseViews + "feedReport";
    }

    //进入兽药记录
    @GetMapping("veterinaryDrugsReport")
    private String veterinaryDrugsReport(Model model, HttpServletRequest request, HttpServletResponse response) {  //List <CityAreaDto> cityAreaDtoList=serachCityAreaDtoInBreefctory();
        //List<BreedFactory> breedFactoryList=findAllBreedFactory();
        Map map = getarea(response, request);
        model.addAttribute("cityAreaDtoList", map.get("cityAreaDtoList"));
        model.addAttribute("breedFactoryList", map.get("breedFactorys"));
        model.addAttribute("username", map.get("username"));
        return BaseViews + "veterinaryDrugsReport";
    }

    /**
     * 进入生产中心ajax
     *
     * @param page
     * @param rows
     * @param breedFactoryId
     * @param time1
     * @param time2
     * @return
     */
    @ResponseBody
    @RequestMapping("prodrecord/select")
    private PagingMz<ProductionReport> search(@RequestParam(required = false) Integer page,
                                              @RequestParam(required = false) Integer rows,
                                              @RequestParam(required = false) String breedFactoryId,
                                              @RequestParam(required = false) Date time1,
                                              @RequestParam(required = false) Date time2) {
        Map criteria = new HashMap();
        if (page == null) {
            page = 1;
        }
        if (rows == null) {
            rows = 20;
        }
        if (breedFactoryId == null) {
            criteria.put("breedFactoryIds", null);
        } else {
            List<Long> list1 = new ArrayList<>();
            String[] list = breedFactoryId.split(",");

            for (int i = 0; i < list.length; i++) {
                int id = Integer.parseInt(list[i]);
                Long id1 = Integer.toUnsignedLong(id);
                list1.add(id1);
            }
            criteria.put("breedFactoryIds", list1);
        }
        criteria.put("deleteFlag", 1);
        criteria.put("time1", time1);
        criteria.put("time2", time2);
        Response<Paging<ProductionReport>> pagingResponse = productionReportReadService.pagingbytimes(page, rows, criteria);
        Long records = pagingResponse.getResult().getTotal(); //总记录数
        Long pagetotal = (records - 1) / rows + 1; //得到总页数
        return new PagingMz<ProductionReport>(pagetotal, records, page, pagingResponse.getResult().getData());
    }


    //饲料记录

    //兽药记录

    //防疫中心

    //免疫记录
    @GetMapping("ImmunizationRecord")
    private String ImmunizationRecord(Model model, HttpServletRequest request, HttpServletResponse response) {

        Map map = getarea(response, request);
        model.addAttribute("cityAreaDtoList", map.get("cityAreaDtoList"));
        model.addAttribute("breedFactoryList", map.get("breedFactorys"));
        model.addAttribute("username", map.get("username"));

        return BaseViews + "ImmunizationRecord";
    }

    /**
     * 进入免疫记录ajax
     *
     * @param page
     * @param rows
     * @param type
     * @param time1
     * @param time2
     * @return
     */
    @ResponseBody
    @RequestMapping("ImmunizationRecord/select")
    private PagingMz<ImmunizationSubRecord> search4(@RequestParam(required = false) Integer page,
                                                    @RequestParam(required = false) Integer rows,
                                                    @RequestParam(required = false) String type,
                                                    @RequestParam(required = false) String breedFactoryId,
                                                    @RequestParam(required = false) Date time1,
                                                    @RequestParam(required = false) Date time2) {
        Map criteria = new HashMap();
        if (page == null) {
            page = 1;
        }
        if (rows == null) {
            rows = 20;
        }
        if (type == null) {
            criteria.put("types", null);
        } else {
            List<Long> list1 = new ArrayList<>();
            String[] list = type.split(",");

            for (int i = 0; i < list.length; i++) {
                int id = Integer.parseInt(list[i]);
                Long id1 = Integer.toUnsignedLong(id);
                list1.add(id1);
            }
            criteria.put("types", list1);
        }
        if (breedFactoryId == null) {
            criteria.put("vaccineIds", null);
        } else {
            List<Long> list1 = new ArrayList<>();
            String[] list = breedFactoryId.split(",");

            for (int i = 0; i < list.length; i++) {
                int id = Integer.parseInt(list[i]);
                Long id1 = Integer.toUnsignedLong(id);
                list1.add(id1);
            }
            Map mapids = new HashMap();
            mapids.put("breedFactoryIds", list1);
            List<Long> vaccineIds = new ArrayList<>();
            List<ImmunizationRecord> immunizationRecordList = immunizationRecordReadService.pagingImmunizationRecordGqv1(1, 10000, mapids).getResult().getData();
            for (ImmunizationRecord immunizationRecord : immunizationRecordList) {
                vaccineIds.add(immunizationRecord.getId());
            }
            if (vaccineIds.size() == 0) {
                vaccineIds.add(-1L);
            }
            criteria.put("vaccineIds", vaccineIds);
        }
        criteria.put("deleteFlag", 1);
        criteria.put("fromDate", time1);
        criteria.put("toDate", time2);
        Response<Paging<ImmunizationSubRecord>> pagingResponse = immunizationSubRecordReadService.pagingImmunizationRecordGqv1(page, rows, criteria);
        Long records = pagingResponse.getResult().getTotal(); //总记录数
        Long pagetotal = (records - 1) / rows + 1; //得到总页数
        return new PagingMz<ImmunizationSubRecord>(pagetotal, records, page, pagingResponse.getResult().getData());

    }

    //消毒记录
    @GetMapping("disinfectReport")
    private String disinfectReport(Model model, HttpServletRequest request, HttpServletResponse response)

    {
        Map map = getarea(response, request);
        model.addAttribute("cityAreaDtoList", map.get("cityAreaDtoList"));
        model.addAttribute("breedFactoryList", map.get("breedFactorys"));
        model.addAttribute("username", map.get("username"));

        return BaseViews + "disinfectReport";
    }

    /**
     * 进入消毒记录ajax
     *
     * @param page
     * @param rows
     * @param breedType
     * @param drugName
     * @param time1
     * @param time2
     * @return
     */
    @ResponseBody
    @RequestMapping("disinfectReport/select")
    private PagingMz<DisinfectReport> search6(@RequestParam(required = false) Integer page,
                                              @RequestParam(required = false) Integer rows,
                                              @RequestParam(required = false) Integer breedType,
                                              @RequestParam(required = false) String drugName,
                                              @RequestParam(required = false) String breedFactoryId,
                                              @RequestParam(required = false) Date time1,
                                              @RequestParam(required = false) Date time2) {
        Map criteria = new HashMap();
        if (page == null) {
            page = 1;
        }
        if (rows == null) {
            rows = 20;
        }
        if (breedType == null) {
            criteria.put("productType", null);
        } else if (breedType == -1) {
            criteria.put("productType", null);
        } else {

            criteria.put("productType", breedType);
        }

        if (drugName == null) {

            criteria.put("drugName", null);
        } else if (drugName == "") {
            criteria.put("drugName", null);
        } else {

            criteria.put("drugName", drugName);
        }

        if (breedFactoryId == null) {
            criteria.put("breedFactoryIds", null);
        } else {
            List<Long> list1 = new ArrayList<>();
            String[] list = breedFactoryId.split(",");

            for (int i = 0; i < list.length; i++) {
                int id = Integer.parseInt(list[i]);
                Long id1 = Integer.toUnsignedLong(id);
                list1.add(id1);
            }
            criteria.put("breedFactoryIds", list1);
        }
        criteria.put("deleteFlag", 1);
        criteria.put("fromDate", time1);
        criteria.put("toDate", time2);
        Response<Paging<DisinfectReport>> pagingResponse = disinfectReportReadService.pagingDisinfectReportGqv(page, rows, criteria);
        Long records = pagingResponse.getResult().getTotal(); //总记录数
        Long pagetotal = (records - 1) / rows + 1; //得到总页数
        return new PagingMz<DisinfectReport>(pagetotal, records, page, pagingResponse.getResult().getData());

    }

    //诊疗记录
    @GetMapping("diagnosisReport")
    private String diagnosisReport(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map map = getarea(response, request);
        model.addAttribute("cityAreaDtoList", map.get("cityAreaDtoList"));
        model.addAttribute("breedFactoryList", map.get("breedFactorys"));
        model.addAttribute("username", map.get("username"));

        return BaseViews + "diagnosisReport";
    }

    /**
     * 进入诊疗记录ajax
     *
     * @param page
     * @param rows
     * @param breedType
     * @param illnessReason
     * @param time1
     * @param time2
     * @return
     */
    @ResponseBody
    @RequestMapping("diagnosisReport/select")
    private PagingMz<DiagnosisReport> search7(@RequestParam(required = false) Integer page,
                                              @RequestParam(required = false) Integer rows,
                                              @RequestParam(required = false) Integer breedType,
                                              @RequestParam(required = false) String illnessReason,
                                              @RequestParam(required = false) String breedFactoryId,
                                              @RequestParam(required = false) Date time1,
                                              @RequestParam(required = false) Date time2) {
        Map criteria = new HashMap();
        if (page == null) {
            page = 1;
        }
        if (rows == null) {
            rows = 20;
        }
        if (breedType == null) {
            criteria.put("productType", null);
        } else if (breedType == -1) {
            criteria.put("productType", null);
        } else {

            criteria.put("productType", breedType);
        }

        if (illnessReason == null) {

            criteria.put("illnessReason", null);
        } else if (illnessReason == "") {
            criteria.put("illnessReason", null);
        } else {

            criteria.put("illnessReason", illnessReason);
        }
        if (breedFactoryId == null) {
            criteria.put("breedFactoryIds", null);
        } else {
            List<Long> list1 = new ArrayList<>();
            String[] list = breedFactoryId.split(",");

            for (int i = 0; i < list.length; i++) {
                int id = Integer.parseInt(list[i]);
                Long id1 = Integer.toUnsignedLong(id);
                list1.add(id1);
            }
            criteria.put("breedFactoryIds", list1);
        }
        criteria.put("deleteFlag", 1);
        criteria.put("fromDate", time1);
        criteria.put("toDate", time2);
        Response<Paging<DiagnosisReport>> pagingResponse = diagnosisReportReadService.pagingDiagnosisReportGqv(page, rows, criteria);
        Long records = pagingResponse.getResult().getTotal(); //总记录数
        Long pagetotal = (records - 1) / rows + 1; //得到总页数
        return new PagingMz<DiagnosisReport>(pagetotal, records, page, pagingResponse.getResult().getData());

    }

    //检验检测
    @GetMapping("ImmunizationDetection")
    private String ImmunizationDetection(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map map = getarea(response, request);
        model.addAttribute("cityAreaDtoList", map.get("cityAreaDtoList"));
        model.addAttribute("breedFactoryList", map.get("breedFactorys"));
        model.addAttribute("username", map.get("username"));

        return BaseViews + "ImmunizationDetection";
    }

    /**
     * 进入检验检测ajax
     *
     * @param page
     * @param rows
     * @param breedType
     * @param type
     * @param time1
     * @param time2
     * @return
     */
    @ResponseBody
    @RequestMapping("ImmunizationDetection/select")
    private PagingMz<ImmunizationDetection> search8(@RequestParam(required = false) Integer page,
                                                    @RequestParam(required = false) Integer rows,
                                                    @RequestParam(required = false) Integer breedType,
                                                    @RequestParam(required = false) Integer type,
                                                    @RequestParam(required = false) String breedFactoryId,
                                                    @RequestParam(required = false) Date time1,
                                                    @RequestParam(required = false) Date time2) {
        Map criteria = new HashMap();
        if (page == null) {
            page = 1;
        }
        if (rows == null) {
            rows = 20;
        }
        if (breedType == null) {
            criteria.put("productType", null);
        } else if (breedType == -1) {
            criteria.put("productType", null);
        } else {

            criteria.put("productType", breedType);
        }

        if (type == null) {

            criteria.put("type", null);
        } else if (type == -1) {
            criteria.put("type", null);

        } else {

            criteria.put("type", type);
        }

        if (breedFactoryId == null) {
            criteria.put("breedFactoryIds", null);
        } else {
            List<Long> list1 = new ArrayList<>();
            String[] list = breedFactoryId.split(",");

            for (int i = 0; i < list.length; i++) {
                int id = Integer.parseInt(list[i]);
                Long id1 = Integer.toUnsignedLong(id);
                list1.add(id1);
            }
            criteria.put("breedFactoryIds", list1);
        }
        criteria.put("deleteFlag", 1);
        criteria.put("fromDate", time1);
        criteria.put("toDate", time2);
        Response<Paging<ImmunizationDetection>> pagingResponse = immunizationDetectionReadService.pagingImmunizationDetectionGqv(page, rows, criteria);
        Long records = pagingResponse.getResult().getTotal(); //总记录数
        Long pagetotal = (records - 1) / rows + 1; //得到总页数
        return new PagingMz<ImmunizationDetection>(pagetotal, records, page, pagingResponse.getResult().getData());

    }


    //无害处理

    @GetMapping("quarantineCenterHarmless")
    private String quarantineCenterHarmless(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map map = getarea(response, request);
        model.addAttribute("cityAreaDtoList", map.get("cityAreaDtoList"));
        model.addAttribute("breedFactoryList", map.get("breedFactorys"));
        model.addAttribute("username", map.get("username"));


        return BaseViews + "quarantineCenterHarmless";
    }

    /**
     * 进入防疫中心无害化ajax
     *
     * @param page
     * @param rows
     * @param breedType
     * @param treatment
     * @param time1
     * @param time2
     * @return
     */
    @ResponseBody
    @RequestMapping("quarantineCenterHarmless/select")
    private PagingMz<QuarantineCenterHarmless> search9(@RequestParam(required = false) Integer page,
                                                       @RequestParam(required = false) Integer rows,
                                                       @RequestParam(required = false) String breedFactoryId,
                                                       @RequestParam(required = false) Integer breedType,
                                                       @RequestParam(required = false) Integer treatment,
                                                       @RequestParam(required = false) Date time1,
                                                       @RequestParam(required = false) Date time2) {
        Map criteria = new HashMap();
        if (page == null) {
            page = 1;
        }
        if (rows == null) {
            rows = 20;
        }
        if (breedType == null) {
            criteria.put("productType", null);
        } else if (breedType == -1) {
            criteria.put("productType", null);
        } else {

            criteria.put("productType", breedType);
        }

        if (treatment == null) {

            criteria.put("treatment", null);
        } else if (treatment == -1) {
            criteria.put("treatment", null);

        } else {

            criteria.put("treatment", treatment);
        }
        if (breedFactoryId == null) {
            criteria.put("breedFactoryIds", null);
        } else {
            List<Long> list1 = new ArrayList<>();
            String[] list = breedFactoryId.split(",");

            for (int i = 0; i < list.length; i++) {
                int id = Integer.parseInt(list[i]);
                Long id1 = Integer.toUnsignedLong(id);
                list1.add(id1);
            }
            criteria.put("breedFactoryIds", list1);
        }

        criteria.put("deleteFlag", 1);
        criteria.put("status", 1);
        criteria.put("fromDate", time1);
        criteria.put("toDate", time2);
        Response<Paging<QuarantineCenterHarmless>> pagingResponse = quarantineCenterHarmlessReadService.pagingQuarantineCenterHarmlessGqv(page, rows, criteria);
        List<QuarantineCenterHarmless> list = pagingResponse.getResult().getData();
        for (QuarantineCenterHarmless quarantineCenterHarmless : list) {
            quarantineCenterHarmless.setEarNumbers(quarantineCenterHarmless.getEarNumbers());
        }
        Long records = pagingResponse.getResult() == null ? 0L : pagingResponse.getResult().getTotal(); //总记录数
        Long pagetotal = (records - 1) / rows + 1; //得到总页数
        return new PagingMz<QuarantineCenterHarmless>(pagetotal, records, page, pagingResponse.getResult() == null ? null : pagingResponse.getResult().getData());

    }


//采购中心

    //原料购置
    @GetMapping("filematerial")
    private String fileMaterial(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map map = getarea(response, request);
        model.addAttribute("areaList", map.get("cityAreaDtoList"));
        model.addAttribute("breedFactoryList", map.get("breedFactorys"));
        model.addAttribute("username", map.get("username"));


        return BaseViews + "file-material";
    }

    @GetMapping("filematerialindex")
    @ResponseBody
    private PagingMz<MaterialPurchaseRecord> showFileMaterialIndex(@RequestParam(required = false) Integer page,
                                                                   @RequestParam(required = false) Integer rows,
                                                                   @RequestParam(required = false) Date start,
                                                                   @RequestParam(required = false) Date end,
                                                                   @RequestParam(required = false) String area,
                                                                   @RequestParam(required = false) Integer name
    ) {
        Map criteria = new HashMap();


        List<BreedFactory> facList = findFactoryIdByArea(area, -1);

        criteria.clear();
        if (start != null) {
            criteria.put("fromDate", start);
        }
        if (end != null) {
            criteria.put("toDate", end);
        }
        if (name != null && name != 0) {
            criteria.put("productName", name);
        }
        criteria.put("deleteFlag", 1);
        Paging<MaterialPurchaseRecord> paging = materialPurchaseRecordReadService.pagingMaterialPurchaseRecordByKeyWords(page, rows, criteria).getResult();
        Long records = paging.getTotal();
        Long pagetotal = (records - 1) / rows + 1;
        List<MaterialPurchaseRecord> materList = new ArrayList<>();
        for (MaterialPurchaseRecord mater : paging.getData()) {
            for (BreedFactory fac : facList) {
                if (mater.getBreedFactoryId().equals(fac.getId())) {
                    materList.add(mater);
                }
            }
        }
        return new PagingMz<>(pagetotal, records, page, materList);
    }

    @GetMapping("material")
    private String material() {
        return BaseViews + "materiaDetail";
    }


    //药物购置
    @GetMapping("drugPurchaseRecord")
    private String drugPurchaseRecord(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map map = getarea(response, request);
        model.addAttribute("cityAreaDtoList", map.get("cityAreaDtoList"));

        model.addAttribute("breedFactoryList", map.get("breedFactorys"));
        model.addAttribute("username", map.get("username"));

        return BaseViews + "drugPurchaseRecord";
    }

    /**
     * 进入药物购置ajax
     *
     * @param page
     * @param rows
     * @param productName
     * @param time1
     * @param time2
     * @return
     */

    @ResponseBody
    @RequestMapping("drugPurchaseRecord/select")
    private PagingMz<DrugPurchaseRecord> search10(@RequestParam(required = false) Integer page,
                                                  @RequestParam(required = false) Integer rows,
                                                  @RequestParam(required = false) String productName,
                                                  @RequestParam(required = false) String breedFactoryId,
                                                  @RequestParam(required = false) Date time1,
                                                  @RequestParam(required = false) Date time2) {
        Map criteria = new HashMap();
        if (page == null) {
            page = 1;
        }
        if (rows == null) {
            rows = 20;
        }


        if (productName == null) {

            criteria.put("productName", null);
        } else if (productName == "") {
            criteria.put("productName", null);

        } else {

            criteria.put("productName", productName);
        }
        if (breedFactoryId == null) {
            criteria.put("breedFactoryIds", null);
        } else {
            List<Long> list1 = new ArrayList<>();
            String[] list = breedFactoryId.split(",");

            for (int i = 0; i < list.length; i++) {
                int id = Integer.parseInt(list[i]);
                Long id1 = Integer.toUnsignedLong(id);
                list1.add(id1);
            }
            criteria.put("breedFactoryIds", list1);
        }
        criteria.put("deleteFlag", 1);
        criteria.put("fromDate", time1);
        criteria.put("toDate", time2);
        Response<Paging<DrugPurchaseRecord>> pagingResponse = drugPurchaseRecordReadService.pagingDrugPurchaseRecordGqv(page, rows, criteria);
        Long records = pagingResponse.getResult() == null ? 0L : pagingResponse.getResult().getTotal(); //总记录数
        Long pagetotal = (records - 1) / rows + 1; //得到总页数
        return new PagingMz<DrugPurchaseRecord>(pagetotal, records, page, pagingResponse.getResult() == null ? null : pagingResponse.getResult().getData());

    }

    //疫苗购置
    @GetMapping("vaccinePurchaseRecord")
    private String vaccinePurchaseRecord(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map map = getarea(response, request);
        model.addAttribute("cityAreaDtoList", map.get("cityAreaDtoList"));

        model.addAttribute("breedFactoryList", map.get("breedFactorys"));
        model.addAttribute("username", map.get("username"));

        return BaseViews + "vaccinePurchaseRecord";
    }

    /**
     * 进入疫苗购置ajax
     *
     * @param page
     * @param rows
     * @param breedType
     * @param productName
     * @param time1
     * @param time2
     * @return
     */
    @ResponseBody
    @RequestMapping("vaccinePurchaseRecord/select")
    private PagingMz<VaccinePurchaseRecord> search11(@RequestParam(required = false) Integer page,
                                                     @RequestParam(required = false) Integer rows,
                                                     @RequestParam(required = false) Integer breedType,
                                                     @RequestParam(required = false) String productName,
                                                     @RequestParam(required = false) String area,
                                                     @RequestParam(required = false) Date time1,
                                                     @RequestParam(required = false) Date time2) {
        Map criteria = new HashMap();
        if (page == null) {
            page = 1;
        }
        if (rows == null) {
            rows = 20;
        }
        if (breedType == null) {
            criteria.put("breedType", null);
        } else if (breedType == -1) {
            criteria.put("breedType", null);
        } else {

            criteria.put("breedType", breedType);
        }

        if (productName == null) {


            criteria.put("productName", null);
        } else if (productName == "") {
            criteria.put("productName", null);

        } else {
            List<Long> list1 = new ArrayList<>();
            String[] list = productName.split(",");

            for (int i = 0; i < list.length; i++) {
                int id = Integer.parseInt(list[i]);
                Long id1 = Integer.toUnsignedLong(id);
                list1.add(id1);
            }
            criteria.put("productName", list1);
        }
        List<BreedFactory> facList = findFactoryIdByArea(area, -1);
        List<Long> breedFactoryIds = new ArrayList<>();
        for (BreedFactory breedFactory : facList) {
            breedFactoryIds.add(breedFactory.getId());
        }
        criteria.put("deleteFlag", 1);
        criteria.put("breedFactoryIds", breedFactoryIds);
        criteria.put("fromDate", time1);
        criteria.put("toDate", time2);
        Response<Paging<VaccinePurchaseRecord>> pagingResponse = vaccinePurchaseRecordReadService.pagingVaccinePurchaseRecordGqv(page, rows, criteria);
        Long records = pagingResponse.getResult() == null ? 0L : pagingResponse.getResult().getTotal(); //总记录数
        Long pagetotal = (records - 1) / rows + 1; //得到总页数
        return new PagingMz<VaccinePurchaseRecord>(pagetotal, records, page, pagingResponse.getResult() == null ? null : pagingResponse.getResult().getData());

    }


    //引种记录

    @GetMapping("seedPurchaseRecord")
    private String seedPurchaseRecord(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map map = getarea(response, request);
        model.addAttribute("cityAreaDtoList", map.get("cityAreaDtoList"));

        model.addAttribute("breedFactoryList", map.get("breedFactorys"));
        model.addAttribute("username", map.get("username"));
        return BaseViews + "seedPurchaseRecord";
    }

    /**
     * 进入引种记录ajax
     *
     * @param page
     * @param rows
     * @param breedFactoryId
     * @param productName
     * @param time1
     * @param time2
     * @return
     */
    @ResponseBody
    @RequestMapping("seedPurchaseRecord/select")
    private PagingMz<SeedPurchaseRecord> search12(@RequestParam(required = false) Integer page,
                                                  @RequestParam(required = false) Integer rows,
                                                  @RequestParam(required = false) String breedFactoryId,
                                                  @RequestParam(required = false) String productName,
                                                  @RequestParam(required = false) Date time1,
                                                  @RequestParam(required = false) Date time2) {
        Map criteria = new HashMap();
        if (page == null) {
            page = 1;
        }
        if (rows == null) {
            rows = 20;
        }
        if (breedFactoryId == null) {
            criteria.put("breedFactoryIds", null);
        } else {
            List<Long> list1 = new ArrayList<>();
            String[] list = breedFactoryId.split(",");

            for (int i = 0; i < list.length; i++) {
                int id = Integer.parseInt(list[i]);
                Long id1 = Integer.toUnsignedLong(id);
                list1.add(id1);
            }
            criteria.put("breedFactoryIds", list1);
        }
        if (productName == null) {

            criteria.put("productName", null);
        } else if (productName.equals("")) {
            criteria.put("productName", null);

        } else {

            criteria.put("productName", productName);
        }
        criteria.put("deleteFlag", 1);
        criteria.put("fromDate", time1);
        criteria.put("toDate", time2);
        Response<Paging<SeedPurchaseRecord>> pagingResponse = seedPurchaseRecordReadService.pagingSeedPurchaseRecordGqv(page, rows, criteria);
        Long records = pagingResponse.getResult() == null ? 0L : pagingResponse.getResult().getTotal(); //总记录数
        Long pagetotal = (records - 1) / rows + 1; //得到总页数
        return new PagingMz<SeedPurchaseRecord>(pagetotal, records, page, pagingResponse.getResult() == null ? null : pagingResponse.getResult().getData());

    }


    //其它购买
    @GetMapping("OtherPurchaseRecord")
    private String OtherPurchaseRecord(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map map = getarea(response, request);
        model.addAttribute("cityAreaDtoList", map.get("cityAreaDtoList"));

        model.addAttribute("breedFactoryList", map.get("breedFactorys"));
        model.addAttribute("username", map.get("username"));

        return BaseViews + "OtherPurchaseRecord";
    }

    /**
     * 进入其它记录ajax
     *
     * @param page
     * @param rows
     * @param breedFactoryId
     * @param productName
     * @param time1
     * @param time2
     * @return
     */
    @ResponseBody
    @RequestMapping("OtherPurchaseRecord/select")
    private PagingMz<OtherPurchaseRecord> search13(@RequestParam(required = false) Integer page,
                                                   @RequestParam(required = false) Integer rows,
                                                   @RequestParam(required = false) String breedFactoryId,
                                                   @RequestParam(required = false) String productName,
                                                   @RequestParam(required = false) Date time1,
                                                   @RequestParam(required = false) Date time2) {
        Map criteria = new HashMap();
        if (page == null) {
            page = 1;
        }
        if (rows == null) {
            rows = 20;
        }
        if (breedFactoryId == null) {
            criteria.put("breedFactoryIds", null);
        } else {
            List<Long> list1 = new ArrayList<>();
            String[] list = breedFactoryId.split(",");

            for (int i = 0; i < list.length; i++) {
                int id = Integer.parseInt(list[i]);
                Long id1 = Integer.toUnsignedLong(id);
                list1.add(id1);
            }
            criteria.put("breedFactoryIds", list1);
        }
        if (productName == null) {

            criteria.put("productName", null);
        } else if (productName.equals("")) {
            criteria.put("productName", null);

        } else {

            criteria.put("productName", productName);
        }
        criteria.put("deleteFlag", 1);
        criteria.put("fromDate", time1);
        criteria.put("toDate", time2);
        Response<Paging<OtherPurchaseRecord>> pagingResponse = otherPurchaseRecordReadService.pagingOtherPurchaseRecordsGov(page, rows, criteria);
        Long records = pagingResponse.getResult().getTotal(); //总记录数
        Long pagetotal = (records - 1) / rows + 1; //得到总页数
        return new PagingMz<OtherPurchaseRecord>(pagetotal, records, page, pagingResponse.getResult().getData());

    }


//治污中心

    //治污中心
    @GetMapping("filepollute")
    private String filepollute(Model model, HttpServletRequest request, HttpServletResponse response) {
        Map map = getarea(response, request);
        model.addAttribute("areaList", map.get("cityAreaDtoList"));

        model.addAttribute("breedFactoryList", map.get("breedFactorys"));
        model.addAttribute("username", map.get("username"));

        Map summap = pollutionControlReadService.sumDryAndLiquidByBreedFactoryId(new HashMap()).getResult();
        model.addAttribute("summap", summap);
        return BaseViews + "file_pollute";
    }

    @GetMapping("pollutionIndex")
    @ResponseBody
    private PagingMz<PollutionControl> showPollutionIndex(@RequestParam(required = false) Integer page,
                                                          @RequestParam(required = false) Integer rows,
                                                          @RequestParam(required = false) Date start,
                                                          @RequestParam(required = false) Date end,
                                                          @RequestParam(required = false) String area
    ) {
        Map criteria = new HashMap();

        Map map = pollutionControlReadService.sumGovernment(null, null, null).getResult();
        List<BreedFactory> facList = findFactoryIdByArea(area, -1);
        List<Long> ids = new ArrayList<>();
        if (facList != null && facList.size() > 0) {
            for (BreedFactory fac : facList) {
                ids.add(fac.getId());
            }
        }
        Paging<PollutionControl> paging = pollutionControlReadService.pagingAll(page, rows, ids, start, end).getResult();
        List<PollutionControl> pollList = new ArrayList<>();
        Float dryAll = 0f;
        Float liquidAll = 0f;
        if (paging != null) {
            for (PollutionControl poll : paging.getData()) {
                for (BreedFactory fac : facList) {
                    if (poll.getBreedFactoryId().equals(fac.getId())) {
                        pollList.add(poll);
                        if (poll.getLiquidUsedQuantity() != null) {
                            liquidAll += poll.getLiquidUsedQuantity();
                            dryAll += poll.getDryUsedQuantity();
                        }
                    }
                }
            }
        }

        DecimalFormat df = new DecimalFormat("#.00");
        PollutionControl pollutionControl = new PollutionControl();
        pollutionControl.setId(-1L);
        pollutionControl.setDryUsedQuantity(Float.parseFloat(df.format(dryAll)));
        pollutionControl.setLiquidUsedQuantity(Float.parseFloat(df.format(liquidAll)));
        if (pollList.size() > 0) {
            pollList.add(pollutionControl);
        }

 /*       PollutionControl pollutionControl1 = new PollutionControl();
        pollutionControl1.setLiquidUsedQuantity((Float)map.get("liquid"));
        pollutionControl1.setDryUsedQuantity((Float)map.get("dry"));*/
        Long records = paging.getTotal();
        Long pagetotal = (records - 1) / rows + 1;

        return new PagingMz<>(pagetotal, records, page, pollList);

    }

    @GetMapping("pollute")
    private String pollute() {
        return BaseViews + "polluteDetail";
    }


    //////////////////////////////////////////////////


    /**
     * 进入饲料记录ajax
     *
     * @param page
     * @param rows
     * @param breedFactoryId
     * @param time1
     * @param time2
     * @return
     */
    @ResponseBody
    @RequestMapping("feedReport/select")
    private PagingMz<FeedReport> search2(@RequestParam(required = false) Integer page,
                                         @RequestParam(required = false) Integer rows,
                                         @RequestParam(required = false) Integer feedType,
                                         @RequestParam(required = false) String breedFactoryId,
                                         @RequestParam(required = false) Date time1,
                                         @RequestParam(required = false) Date time2) {
        Map criteria = new HashMap();
        if (page == null) {
            page = 1;
        }
        if (rows == null) {
            rows = 20;
        }
        if (breedFactoryId == null) {
            criteria.put("breedFactoryIds", null);
        } else {
            List<Long> list1 = new ArrayList<>();
            String[] list = breedFactoryId.split(",");

            for (int i = 0; i < list.length; i++) {
                int id = Integer.parseInt(list[i]);
                Long id1 = Integer.toUnsignedLong(id);
                list1.add(id1);
            }
            criteria.put("breedFactoryIds", list1);

        }
        if (feedType == null) {

            criteria.put("feedType", null);
        } else if (feedType == -1) {
            criteria.put("feedType", null);
        } else {

            criteria.put("feedType", feedType);
        }
        criteria.put("deleteFlag", 1);
        criteria.put("time1", time1);
        criteria.put("time2", time2);
        Response<Paging<FeedReport>> pagingResponse = feedReportReadService.pagingbytimes(page, rows, criteria);
        Long records = pagingResponse.getResult().getTotal(); //总记录数
        Long pagetotal = (records - 1) / rows + 1; //得到总页数
        return new PagingMz<FeedReport>(pagetotal, records, page, pagingResponse.getResult().getData());
    }

    /**
     * 进入兽药记录ajax
     *
     * @param page
     * @param rows
     * @param useMethod
     * @param breedFactoryId
     * @param time1
     * @param time2
     * @return
     */
    @ResponseBody
    @RequestMapping("veterinaryDrugsReport/select")
    private PagingMz<VeterinaryDrugsReport> search1(@RequestParam(required = false) Integer page,
                                                    @RequestParam(required = false) Integer rows,
                                                    @RequestParam(required = false) Integer useMethod,
                                                    @RequestParam(required = false) String breedFactoryId,
                                                    @RequestParam(required = false) Date time1,
                                                    @RequestParam(required = false) Date time2) {
        Map criteria = new HashMap();
        if (page == null) {
            page = 1;
        }
        if (rows == null) {
            rows = 20;
        }
        if (breedFactoryId == null) {
            criteria.put("breedFactoryIds", null);
        } else {
            List<Long> list1 = new ArrayList<>();
            String[] list = breedFactoryId.split(",");

            for (int i = 0; i < list.length; i++) {
                int id = Integer.parseInt(list[i]);
                Long id1 = Integer.toUnsignedLong(id);
                list1.add(id1);
            }
            criteria.put("breedFactoryIds", list1);
        }
        if (useMethod == null) {

            criteria.put("useMethod", null);
        } else if (useMethod == -1) {
            criteria.put("useMethod", null);
        } else {

            criteria.put("useMethod", useMethod);
        }
        criteria.put("deleteFlag", 1);
        criteria.put("time1", time1);
        criteria.put("time2", time2);
        Response<Paging<VeterinaryDrugsReport>> pagingResponse = veterinaryDrugsReportReadService.pagingbytimes(page, rows, criteria);
        Long records = pagingResponse.getResult().getTotal(); //总记录数
        Long pagetotal = (records - 1) / rows + 1; //得到总页数
        return new PagingMz<VeterinaryDrugsReport>(pagetotal, records, page, pagingResponse.getResult().getData());

    }

    /**
     * 根据区域和养殖类型查询 养殖场
     *
     * @param region
     * @param breedType
     * @return
     */
    @ResponseBody
    @RequestMapping("search")
    public List findFactoryIdByArea(@RequestParam String region, @RequestParam int breedType) {

        Map map = new HashMap();
        if (breedType == -1) {
            map.put("breedType", null);
        } else {
            map.put("breedType", breedType);
        }
        List<String> list1 = new ArrayList<>();
        if (region != null) {
            String[] list = region.split(",");

            for (int i = 0; i < list.length; i++) {
                list1.add(list[i]);
            }
        }


        map.put("areas", list1);

        List<BreedFactory> breedFactoryList = (List<BreedFactory>) breedFactoryReadService.findByArea(map).getResult();

        return breedFactoryList;
    }

    /**
     * 查询所有市下面的区
     *
     * @return CityAreaDto
     */

    public List<CityAreaDto> serachCityAreaDtoInBreefctory() {
        List<CityAreaDto> cityAreaDtoArrayList = new ArrayList<>();
        List<String> list = breedFactoryReadService.serachAllCity();

        for (String city : list) {
            CityAreaDto cityAreaDto = new CityAreaDto();
            cityAreaDto.setCity(city);
            List<String> regions = breedFactoryReadService.serachAllregion(city);

            cityAreaDto.setRegions(regions);
            cityAreaDtoArrayList.add(cityAreaDto);
        }

        return cityAreaDtoArrayList;
    }

    //查询所有养殖场
    public List<BreedFactory> findAllBreedFactory() {


        return breedFactoryReadService.pagingBreedRecord(1, 1000000, null).getResult().getData();
    }

    @ResponseBody
    @RequestMapping("amountchert")
    public Map<Integer, Object> findByType(@RequestParam Integer type, @RequestParam Integer limit) {
        Map<String, Object> map = new HashedMap();
        if (limit == null) {
            limit = 1;
        }
        if (type != null) {
            map.put("type", type);
            map.put("limit", limit);
        } else {
            log.error("type not null!");
        }
        Response<Map<Integer, Object>> mapResponse = beastsBreedStockMessageReadService.findByType1(map);
        if (!mapResponse.isSuccess()) {
            log.error("failed to find BeastsBreedStockMessage reocrd by type = {}, cause : {}", type, mapResponse.getError());
            throw new OPServerException(mapResponse.getError());
        }
        return mapResponse.getResult();
    }

    @ResponseBody
    @RequestMapping("proch")
    private Map search111(
            @RequestParam(required = false) String area,
            @RequestParam(required = false) Integer breedType,
            @RequestParam(required = false) Date time1,
            @RequestParam(required = false) Date time2) {
        Map criteria = new HashMap();

        List<BreedFactory> list = findFactoryIdByArea(area, breedType);
        List<Long> longList = new ArrayList<>();

        for (BreedFactory breedFactory : list) {
            longList.add(breedFactory.getId());
        }


        criteria.put("breedFactoryIds", longList);

        criteria.put("time1", time1);
        criteria.put("time2", time2);
        Response<Paging<ProductionReport>> pagingResponse = productionReportReadService.pagingbytimes(1, 10000, criteria);
        Long a = 0L;
        Long b = 0L;
        Long c = 0L;
        Long d = 0L;
        if (pagingResponse.getResult() != null) {
            for (ProductionReport productionReport : pagingResponse.getResult().getData()) {

                a += productionReport.getBirthQuantity();
                b += productionReport.getInQuantity();
                c += productionReport.getOutQuantity();
                d += productionReport.getDeathQuantity();
            }
        }
        Map map = new HashMap();
        map.put("a", a);
        map.put("b", b);
        map.put("c", c);
        map.put("d", d);
        return map;
    }


    @ResponseBody
    @RequestMapping("proch1")
    public List ttt111(@RequestParam(required = false) String area,
                       @RequestParam(required = false) Date time1,
                       @RequestParam(required = false) Date time2) {

        List<BreedFactory> list = findFactoryIdByArea(area, -1);
        List<Long> longList = new ArrayList<>();

        for (BreedFactory breedFactory : list) {
            longList.add(breedFactory.getId());
        }


        List list1 = new ArrayList();
        list1.add(1);
        list1.add(2);
        list1.add(3);
        list1.add(4);
        List<Map> list2 = new ArrayList<>();
        for (int i = 0; i < list1.size(); i++) {

            Map map = new HashMap();
            map.put("fromDate", time1);
            map.put("toDate", time2);
            map.put("breedFactoryIds", longList);
            map.put("type", list1.get(i));
            map.put("limit", 1);
            Response<Map<Integer, Object>> mapResponse = beastsBreedStockMessageReadService.findByType1(map);
            Map<Integer, Object> map1 = mapResponse.getResult();
            list2.add(map1);
        }

        return list2;
    }

    @ResponseBody
    @RequestMapping("proDelete")
    public Boolean proDelete(@RequestParam Long id,
                             @RequestParam Integer deathQuantity,
                             @RequestParam String relateNumber,
                             @RequestParam Long relateId,
                             @RequestParam Long breedId) {
        try {
            ProductionReport productionReport = new ProductionReport();
            productionReport.setDeleteFlag(-1);
            productionReport.setId(id);
            Boolean b = productionReportWriteService.update(productionReport);
            Boolean a = true;
            Boolean c = true;
            if (relateId != null) {
                QuarantineCenterHarmless quarantineCenterHarmless = new QuarantineCenterHarmless();
                quarantineCenterHarmless.setDeleteFlag(-1);
                quarantineCenterHarmless.setId(relateId);
                a = quarantineCenterHarmlessWriteService.update(quarantineCenterHarmless);

            }
            if (deathQuantity > 0) {
                int sum = breedFactoryReadService.findById(breedId).getResult().getStockQuantity() + deathQuantity;
                BreedFactory breedFactory = new BreedFactory();
                breedFactory.setId(breedId);
                breedFactory.setStockQuantity(sum);
                c = breedFactoryWriteService.update(breedFactory).getResult();
            }
            if (a && b && c) {
                return true;
            } else {
                return false;
            }

        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }

    @ResponseBody
    @RequestMapping("feedReportDelete")
    public Boolean feedReportDelete(@RequestParam Long id) {

        try {
            FeedReport feedReport = new FeedReport();
            feedReport.setDeleteFlag(-1);
            feedReport.setId(id);
            Boolean a = feedReportWriteService.update(feedReport);
            return a;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }


    @ResponseBody
    @RequestMapping("veterinaryDelete")
    public Boolean veterinaryDelete(@RequestParam Long id) {

        try {

            VeterinaryDrugsReport veterinaryDrugsReport = new VeterinaryDrugsReport();
            veterinaryDrugsReport.setId(id);
            veterinaryDrugsReport.setDeleteFlag(-1);
            Boolean a = veterinaryDrugsReportWriteService.update(veterinaryDrugsReport);
            return a;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }


    @ResponseBody
    @RequestMapping("ImmunizationDelete")
    public Boolean ImmunizationDelete(@RequestParam Long id) {

        try {

            ImmunizationSubRecord immunizationSubRecord=new ImmunizationSubRecord();
            immunizationSubRecord.setDeleteFlag(-1);
            immunizationSubRecord.setId(id);
            Boolean a = immunizationSubRecordWriteService.update(immunizationSubRecord).getResult();
            return a;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }


    @ResponseBody
    @RequestMapping("disinfectDelete")
    public Boolean disinfectDelete(@RequestParam Long id) {

        try {

            DisinfectReport disinfectReport = new DisinfectReport();
            disinfectReport.setId(id);
            disinfectReport.setDeleteFlag(-1);
            Boolean a = disinfectReportWriteService.update(disinfectReport);
            return a;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }


    @ResponseBody
    @RequestMapping("diagnosisDelete")
    public Boolean diagnosisDelete(@RequestParam Long id) {

        try {

            DiagnosisReport diagnosisReport = new DiagnosisReport();
            diagnosisReport.setId(id);
            diagnosisReport.setDeleteFlag(-1);
            Boolean a = diagnosisReportWriteService.update(diagnosisReport);
            return a;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }


    @ResponseBody
    @RequestMapping("ImmunizationDetectionDelete")
    public Boolean ImmunizationDetectionDelete(@RequestParam Long id) {

        try {

            ImmunizationDetection immunizationDetection = new ImmunizationDetection();
            immunizationDetection.setId(id);
            immunizationDetection.setDeleteFlag(-1);
            Boolean a = immunizationDetectionWriteService.update(immunizationDetection);
            return a;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }

    @ResponseBody
    @RequestMapping("filematerialDelete")
    public Boolean filematerialDelete(@RequestParam Long id) {

        try {

            MaterialPurchaseRecord materialPurchaseRecord = new MaterialPurchaseRecord();
            materialPurchaseRecord.setDeleteFlag(-1);
            materialPurchaseRecord.setId(id);
            Boolean a = materialPurchaseRecordWriteService.update(materialPurchaseRecord);
            return a;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }


    @ResponseBody
    @RequestMapping("drugPurchaseDelete")
    public Boolean drugPurchaseDelete(@RequestParam Long id) {

        try {

            DrugPurchaseRecord drugPurchaseRecord = new DrugPurchaseRecord();
            drugPurchaseRecord.setId(id);
            drugPurchaseRecord.setDeleteFlag(-1);
            Boolean a = drugPurchaseRecordWriteService.update(drugPurchaseRecord);
            return a;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }

    @ResponseBody
    @RequestMapping("vaccineDelete")
    public Boolean vaccineDelete(@RequestParam Long id) {

        try {

            VaccinePurchaseRecord vaccinePurchaseRecord = new VaccinePurchaseRecord();
            vaccinePurchaseRecord.setId(id);
            vaccinePurchaseRecord.setDeleteFlag(-1);
            Boolean a = vaccinePurchaseRecordWriteService.update(vaccinePurchaseRecord);
            return a;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }

    @ResponseBody
    @RequestMapping("seedPurchaseDelete")
    public Boolean seedPurchaseDelete(@RequestParam Long id) {

        try {

            SeedPurchaseRecord seedPurchaseRecord = new SeedPurchaseRecord();
            seedPurchaseRecord.setId(id);
            seedPurchaseRecord.setDeleteFlag(-1);
            Boolean a = seedPurchaseRecordWriteService.update(seedPurchaseRecord);
            return a;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }

    @ResponseBody
    @RequestMapping("OtherPurchaseDelete")
    public Boolean OtherPurchaseDelete(@RequestParam Long id) {

        try {

            OtherPurchaseRecord otherPurchaseRecord = new OtherPurchaseRecord();
            otherPurchaseRecord.setId(id);
            otherPurchaseRecord.setDeleteFlag(-1);
            Boolean a = otherPurchaseRecordWriteService.update(otherPurchaseRecord);
            return a;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }


    @ResponseBody
    @RequestMapping("filepolluteDelete")
    public Boolean filepolluteDelete(@RequestParam Long id) {

        try {

            PollutionControl pollutionControl = new PollutionControl();
            pollutionControl.setId(id);
            pollutionControl.setDeleteFlag(-1);
            Boolean a = pollutionControlWriteService.update(pollutionControl);
            return a;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }

    @ResponseBody
    @RequestMapping("quarantineCenterHarmlessDelete")
    public Boolean quarantineCenterHarmlessDelete(@RequestParam Long id,
                                                  @RequestParam Integer quantity,
                                                  @RequestParam Long breedId) {

        try {


            QuarantineCenterHarmless quarantineCenterHarmless = new QuarantineCenterHarmless();
            quarantineCenterHarmless.setId(id);
            quarantineCenterHarmless.setDeleteFlag(-1);
            Boolean a = quarantineCenterHarmlessWriteService.update(quarantineCenterHarmless);
            if (quantity > 0) {
                int sum = breedFactoryReadService.findById(breedId).getResult().getStockQuantity() + quantity;
                BreedFactory breedFactory = new BreedFactory();
                breedFactory.setId(breedId);
                breedFactory.setStockQuantity(sum);
                breedFactoryWriteService.update(breedFactory);
            }
            return a;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }

    }

    public Map getarea(HttpServletResponse response, HttpServletRequest request) {
        List<String> list = new ArrayList<>();
        list.add("province");
        list.add("city");
        list.add("region");
        list.add("street");
        list.add("village");
        Cookie[] cookies = null;
        cookies = request.getCookies();
        String name = "";
        Map map = new HashMap();
        for (Cookie cookie : cookies) {

            if (cookie.getName().equals("djtid")) {
                String id = cookie.getValue();
                int Id = Integer.parseInt(id);
                Response<User> userResponse = userReadService.findById(Integer.toUnsignedLong(Id));
                name = userResponse.getResult().getName();
                map.put("username", name);
                switch (userResponse.getResult().getAreaLevel()) {
                    case 1:
                        UserProfile userProfile = userProfileReadService.findUserProfileById(userResponse.getResult().getId()).getResult();
                        String Province = userProfile.getProvince();
                        Map map6 = new HashMap();
                        map6.put("province", Province);
                        List<BreedFactory> breedFactoryList = (List<BreedFactory>) breedFactoryReadService.findByArea(map6).getResult();
                        //获取所有省下城市

                        Map map1 = new HashMap();
                        map1.put("area1", list.get(1));
                        map1.put("area2", list.get(0));
                        map1.put("area3", Province);
                        List<String> citys = breedFactoryReadService.serachAllregion1(map1);
                        //获取城市下所有区
                        List<CityAreaDto> cityAreaDtoList = new ArrayList<>();
                        for (String city : citys) {
                            CityAreaDto cityAreaDto = new CityAreaDto();
                            Map map2 = new HashMap();
                            map2.put("area1", list.get(2));
                            map2.put("area2", list.get(1));
                            map2.put("area3", city);
                            List<String> regions = breedFactoryReadService.serachAllregion1(map2);
                            cityAreaDto.setCity(city);
                            cityAreaDto.setRegions(regions);
                            cityAreaDtoList.add(cityAreaDto);

                        }
                        map.put("userProfile", userProfile);
                        map.put("cityAreaDtoList", cityAreaDtoList);
                        map.put("breedFactorys", breedFactoryList);
                        //switch break;
                        break;
                    case 2:
                        UserProfile userProfile2 = userProfileReadService.findUserProfileById(userResponse.getResult().getId()).getResult();
                        String city1 = userProfile2.getCity();
                        Map map7 = new HashMap();
                        map7.put("city", city1);
                        List<BreedFactory> breedFactoryList1 = (List<BreedFactory>) breedFactoryReadService.findByArea(map7).getResult();
                        //获取所有省下城市

                        Map map21 = new HashMap();
                        map21.put("area1", list.get(2));
                        map21.put("area2", list.get(1));
                        map21.put("area3", city1);
                        List<String> citys2 = breedFactoryReadService.serachAllregion1(map21);
                        //获取城市下所有区
                        List<CityAreaDto> cityAreaDtoList1 = new ArrayList<>();
                        for (String city : citys2) {
                            CityAreaDto cityAreaDto = new CityAreaDto();
                            Map map2 = new HashMap();
                            map2.put("area1", list.get(3));
                            map2.put("area2", list.get(2));
                            map2.put("area3", city);
                            List<String> regions = breedFactoryReadService.serachAllregion1(map2);
                            cityAreaDto.setCity(city);
                            cityAreaDto.setRegions(regions);
                            cityAreaDtoList1.add(cityAreaDto);

                        }
                        map.put("userProfile", userProfile2);
                        map.put("cityAreaDtoList", cityAreaDtoList1);
                        map.put("breedFactorys", breedFactoryList1);
                        //switch break;
                        break;
                    case 3://区
                        UserProfile userProfile3 = userProfileReadService.findUserProfileById(userResponse.getResult().getId()).getResult();
                        String region = userProfile3.getRegion();
                        Map map36 = new HashMap();
                        map36.put("region", region);
                        List<BreedFactory> breedFactoryList3 = (List<BreedFactory>) breedFactoryReadService.findByArea(map36).getResult();
                        //获取所有区下城市镇

                        Map map31 = new HashMap();
                        map31.put("area1", list.get(3));
                        map31.put("area2", list.get(2));
                        map31.put("area3", region);
                        List<String> citys3 = breedFactoryReadService.serachAllregion1(map31);
                        //获取对应镇 对应村
                        List<CityAreaDto> cityAreaDtoList3 = new ArrayList<>();
                        for (String city : citys3) {
                            CityAreaDto cityAreaDto = new CityAreaDto();
                            Map map2 = new HashMap();
                            map2.put("area1", list.get(4));
                            map2.put("area2", list.get(3));
                            map2.put("area3", city);
                            List<String> regions = breedFactoryReadService.serachAllregion1(map2);
                            cityAreaDto.setCity(city);
                            cityAreaDto.setRegions(regions);
                            cityAreaDtoList3.add(cityAreaDto);

                        }
                        map.put("userProfile", userProfile3);
                        map.put("cityAreaDtoList", cityAreaDtoList3);
                        map.put("breedFactorys", breedFactoryList3);
                        //switch break;
                        break;
                    case 4://镇
                        UserProfile userProfile4 = userProfileReadService.findUserProfileById(userResponse.getResult().getId()).getResult();
                        String street = userProfile4.getStreet();
                        Map map46 = new HashMap();
                        map46.put("street", street);
                        List<BreedFactory> breedFactoryList4 = (List<BreedFactory>) breedFactoryReadService.findByArea(map46).getResult();
                        //获取所有镇下所有村

                        Map map41 = new HashMap();
                        map41.put("area1", list.get(4));
                        map41.put("area2", list.get(3));
                        map41.put("area3", street);
                        List<String> citys4 = breedFactoryReadService.serachAllregion1(map41);//所有村

                        List<CityAreaDto> cityAreaDtoList4 = new ArrayList<>();

                        CityAreaDto cityAreaDto = new CityAreaDto();

                        cityAreaDto.setCity(street);
                        cityAreaDto.setRegions(citys4);
                        cityAreaDtoList4.add(cityAreaDto);

                        map.put("userProfile", userProfile4);
                        map.put("cityAreaDtoList", cityAreaDtoList4);
                        map.put("breedFactorys", breedFactoryList4);
                        //switch break;
                        break;
                    case 5://村
                        UserProfile userProfile99 = userProfileReadService.findUserProfileById(userResponse.getResult().getId()).getResult();
                        List<GovernmentUserDuty> governmentUserDutyList = governmentUserDutyReadService.findGovernmentUserDutiesByUserId(userResponse.getResult().getId(), null).getResult();
                        List<Long> longlist = new ArrayList<>();
                        for (GovernmentUserDuty governmentUserDuty : governmentUserDutyList) {
                            longlist.add(governmentUserDuty.getFactoryOrPointId());
                        }
                        List<String> villages = new ArrayList<>();
                        List<BreedFactory> breedFactoryList2 = breedFactoryReadService.findBreedFactoryDtoByIds(longlist).getResult();
                        for (BreedFactory breedFactory : breedFactoryList2) {
                            villages.add(breedFactory.getVillage());

                        }

                        List<String> listWithoutDup = new ArrayList<String>(new HashSet<String>(villages));


                        List<CityAreaDto> cityAreaDtoList5 = new ArrayList<>();

                        CityAreaDto cityAreaDto1 = new CityAreaDto();
                        cityAreaDto1.setCity(" ");

                        // cityAreaDto1.setCity(village);
                        cityAreaDto1.setRegions(listWithoutDup);

                        cityAreaDtoList5.add(cityAreaDto1);

                        map.put("userProfile", userProfile99);
                        map.put("cityAreaDtoList", cityAreaDtoList5);
                        map.put("breedFactorys", breedFactoryList2);
                        //switch break;
                        break;
                }


                break;
            }

        }

        return map;
    }


}
